
import React, { useState, useImperativeHandle } from "react";

function One(props, ref) {
    let [isShow, setIsShow] = useState(true)
    useImperativeHandle(ref, () => {
        return {
            isDispaly: function isDispaly() {
                setIsShow(!isShow)
            }
        }
    })
    return (
        <div>
            {isShow && <div style={{
                width: "100px",
                height: '100px',
                backgroundColor: "red",
                textAlign: 'center',
                lineHeight: "100px"
            }}>
                one组件
            </div>}
        </div>
    )
}

export default React.forwardRef(One)